package soft.edu.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import soft.edu.common.ServerResponse;
import soft.edu.dao.SchResearchDirectionMapper;
import soft.edu.pojo.SchResearchDirection;
import soft.edu.service.SchResearchDirectionService;

import java.util.List;

@Controller("schResearchDirectionService")
public class SchResearchDirectionServiceImpl implements SchResearchDirectionService {

    @Autowired
    private SchResearchDirectionMapper schResearchDirectionMapper;

    //    根据院校、学院、专业查研究方向的信息
    @Override
    public ServerResponse<List<SchResearchDirection>> getRDInfo(String year,
            String res_uni_name, String res_college_name, String res_maj_name) {
        List<SchResearchDirection> listSchResearchDirection =
                schResearchDirectionMapper.getRDInfo(year,
                        res_uni_name, res_college_name, res_maj_name);

        if(listSchResearchDirection.isEmpty()){
            return ServerResponse.createByErrorMessage("研究方向查询不到");
        }else{
            return ServerResponse.createBySuccess("研究方向查询成功",listSchResearchDirection);
        }
    }

    //根据院校、学院、专业、年份筛选
    @Override
    public ServerResponse<List<SchResearchDirection>> getRD_byYear(
            String res_year, String res_uni_name, String res_college_name, String res_maj_name) {

        List<SchResearchDirection> listSchResearchDirection =
                schResearchDirectionMapper.getRD_byYear(
                        res_year, res_uni_name,
                        res_college_name, res_maj_name);
        if(listSchResearchDirection.isEmpty()){
            return ServerResponse.createByErrorMessage("研究方向查询不到");
        }else{
            return ServerResponse.createBySuccess("研究方向查询成功",listSchResearchDirection);
        }

    }
}
